<%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025/5/4
  Time: 21:00
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.project.DB_Ticket" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.List" %>
<!DOCTYPE html>
<html>
<head>
  <title>添加票务</title>
</head>
<body>
<h2>添加票务</h2>
<form action="addTicket.jsp" method="post">
  <label for="oid">订单ID:</label>
  <input type="text" id="oid" name="oid" required><br>
  <label for="uid">用户ID:</label>
  <input type="text" id="uid" name="uid" required><br>
  <label for="set">座位:</label>
  <input type="text" id="set" name="set" required><br>
  <input type="submit" value="添加票务">
</form>
<%
  if ("post".equalsIgnoreCase(request.getMethod())) {
    String oid = request.getParameter("oid");
    String uid = request.getParameter("uid");
    String set = request.getParameter("set");

    List<String> addInput = new ArrayList<>();
    addInput.add(oid);
    addInput.add(uid);
    addInput.add(set);

    DB_Ticket dbTicket = new DB_Ticket();
    boolean addResult = dbTicket.add(addInput);

    if (addResult) {
      response.sendRedirect("index.jsp");
    } else {
      out.println("添加票务失败");
    }
  }
%>
</body>
</html>